package com.cf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cf.domain.pojo.Certificate;
import com.cf.domain.pojo.News;
import com.cf.mapper.CertificateMapper;
import com.cf.mapper.NewsMapper;
import com.cf.service.ICertificateService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
@RequiredArgsConstructor
public class CertificateServiceImpl extends ServiceImpl<CertificateMapper, Certificate> implements ICertificateService {

    private final CertificateMapper certificateMapper;

    @Override
    public Page<Certificate> page(Page page, Map<String, Object> map) {
        QueryWrapper<Certificate> wrapper = new QueryWrapper<>();
        wrapper.eq("enable", 0);
//        if(Integer.valueOf(map.get("content").toString())>0){
//            wrapper.eq("type", map.get("typeQuery"));
//        }
        wrapper.orderByDesc("create_time");
        return page(page, wrapper);
    }

    @Override
    public List<Certificate> search(Map<String, Object> map) {
        return certificateMapper.search(map.get("content").toString());
    }
}
